//
//  YLRefreshGifHeader.swift
//  Swift-Codedase
//
//  Created by xyanl on 2023/9/11.
//

import UIKit
import MJRefresh
import Localize_Swift

class YLRefreshGifHeader: MJRefreshGifHeader {
    
    // 在这里做一些初始化配置（比如添加子控件）
    override func prepare() {
        super.prepare()
        
        // 设置控件的高度
        mj_h = 50
        // 初始化间距
        labelLeftInset = 10
        
        // 设置自动切换透明度(在导航栏下面自动隐藏)
        isAutomaticallyChangeAlpha = true
        // 隐藏时间
        lastUpdatedTimeLabel!.isHidden = true
        
        // 设置普通状态的动画图片
        var idleImages = NSMutableArray() as! [UIImage]
        for index in 1...60 {
            let image = UIImage(named: "dropdown_anim__000\(index)")!
            idleImages.append(image)
        }
        setImages(idleImages, for: .idle)
        
        // 设置即将刷新状态的动画图片（一松开就会刷新的状态）
        var refreshingImages = NSMutableArray() as! [UIImage]
        for index in 1...3 {
            let image = UIImage(named: "dropdown_loading_0\(index)")!
            refreshingImages.append(image)
        }
        setImages(refreshingImages, for: .pulling)
        
        // 设置正在刷新状态的动画图片
        setImages(refreshingImages, for: .refreshing)
        
        setTitle("下拉刷新".localized(), for: .idle)
        setTitle("松开刷新".localized(), for: .pulling)
        setTitle("正在刷新".localized(), for: .refreshing)
    }
    
}
